# 容器类型 数据结构
# list --- 数组（其他语言）
# list 特征
# 1.有序项目合集
# 2.里面可以放任何数据类型
# 3.可变数据类型
# a = ["a", "b", "c"]
# a[1] = 2
# print(a)
# print(a[1])
#
# lst1 = []
# if lst1:
#     print("ok")
# else:
#     print("error")
#
# lst2 = list()
# print(lst2)
#
# lst3 = list()
# list 基本用法
#
#
#
# 切片


# slice 对象
# lst1 = ["yt", "tl", "bxj", "xyj", "jgb"]
# slice1 = slice(0, 3, 1)
# print(lst1[slice1])
# lst2 = ["wukong", "shaseng", "zhubajie", "tangseng", "guanyin"]
# print(lst2[slice1])
# print(lst2[0:3:1])

# 小练习
# a = ["apple", "orange", "123", "0.1111", "cali"]
# print(a[1::1])
# print(a[2:7:1])
# print(a[1:-3:1])
# print(a[0], a[-1])
# print(a)


# # 增加
# # append：在末尾，作为整体增加，类型不限
# lst1 = ["a", "b", "c"]
# lst1.append("x")
# print(lst1)
#
# # insert :在index位置插入数据
# lst1.insert(1, "y")
# print(lst1)
#
# # extend
# lst1.extend("123")
# print(lst1)
# # lst1=["aa","bb","cc"]
# lst1.extend(["aa", "bb", "cc"])
# print(lst1)
#
# # +
# print(lst1+["aa", "bb", "cc"])
# print(lst1 + "abc")

# 删除
# lst1 = ["a", "b", "c", "a"]
# # remove 删除找得到的第一个指定元素
# lst1.remove("a")
# print(lst1)
# # 列表里没有指定删除元素就会报错
# # ValueError: list.remove(x): x not in list
# lst1.remove("f")

# pop
# 删除元素，默认删除最后一个，也可以指定index删除
# 返回被删除的元素
# result = lst1.pop()
# print(lst1)
# print(result)
# lst1.pop(1)
# print(lst1)
#
# # clear:清空
# lst1.clear()
# print(lst1)
#
# # del 删除指定元素引用
# print(lst1)
# del lst1[0]
# print(lst1)
# del lst1[:3]
# print(lst1)

# # ## 修改
# # 利用下标或者切片来进行修改
# lst1 = ["a", "b", "c", "d", "e", "f"]
# lst1[0] = "x"
# print(lst1)
# print(lst1[1:1])
# lst1[1:2] = "qwe"
# print(lst1)
# print(lst1.count("e"))
# print(len(lst1))
#
# # #反转
# # lst1 = lst1[::-1]
# print(lst1[::-1])
# lst1.reverse() #对自身进行操作
# print(lst1)
#
# # #排序
# lst1 = ["a", "你好", "hello", "test", "tongle", "快乐"]
# # lst1.sort()#对自身的操作
# # print(lst1)
#
# # #统计
# print(len(lst1))#统计总长度(元素总数)
# print(lst1.count("t"))#统计元素的出现次数
# print(lst1.index("text"))#查看元素下标，没有相应元素就会报错
# # print(lst1.index("t"))

# 拷贝
#copy
# >>>a =[1, 2]
# b = a

# # 遍历
# lst1 = ["a", "你好", "hello", "test", "tongle", "快乐"]
# for i in lst1:
#     print(i)
#
# for j in enumerate(lst1):
#     print(j)
#
# for i, j in enumerate(lst1):
#     print(i, "-->", j)

# #判断成员关系
# in / not in
# lst1 = ["a", "你好", "hello", "test", "tongle", "快乐"]
# print(lst1)
#
# print("b" in lst1)
# if "c" in lst1:
#     print("ok")
# else:
#     print("error")


# 小练习
# lst1 = ["python", "java", "C"]
# lst1.append("我是追加")
# print(lst1)
# del lst1[0]
# del lst1[2]
# print(lst1)
#
# if "Cali" in lst1:
#     print("ok")
# else:
#     print("error")
# print(len(lst1))
# lst2 = ["liu", "cali", "123", "456"]
# print(lst1 + lst2)

